/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>Project: jse2303 - List6
 * <p>Powered by webrx On 2023-07-19 11:38:47
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class List6 {
    public static void main(String[] args) {
        //Array ArrayList 相互转换
        Integer[] is = new Integer[]{1, 2, 3};
        System.out.println(is);

        List<Integer> list = new ArrayList<>(Arrays.asList(is));
        list.add(4);
        System.out.println(list);

        Object[] objs = list.toArray();
        System.out.println(objs.length);
        System.out.println(Arrays.toString(objs));


        Integer[] is2 = new Integer[list.size()];
        list.toArray(is2);
        System.out.println(is2.length);
        System.out.println(Arrays.toString(is2));

        //只读List不排序 添加 删除 不能修改值 如果要操作，new ArrayList<>()
        List<Integer> list1 = Arrays.asList(1, 2, 3);
        List<Integer> list2 = List.of(3, 2, 1);
        list2.clear();
    }
}
